# Prompt the user to choose among the available profiles
echo
echo `gettext "Select a screen profile: "`
i=0
profiles=$(listprofiles)
for x in $profiles; do
i=$(expr $i + 1)
desc=" "
if [ "$x" = "light" ]; then
simple=$i
fi
[ $i -lt 10 ] && i=" $i"
echo " $i. $x$desc"
done
echo
selected=x
count=1
while /bin/true; do
if [ $count -gt 5 ]; then
echo `gettext "ERROR: Invalid selection"`
exit 1
fi
count=`expr $count + 1`
if [ -z "$selected" -a ! -z "$simple" ]; then
selected="$simple"
elif ! test $selected -gt 0 2>/dev/null; then
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
selected=`head -n1`
elif ! test $selected -le $i 2>/dev/null; then
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
selected=`head -n1`
else
break
fi
done
SELECTED="$selected"
}
setprofile() {
# Apply a profile by name or index
if [ -n "$1" ]; then
selected="$1"
else
selected="$SELECTED"
fi
i=0
found=0
profiles=$(listprofiles)
for x in $profiles; do
i=`expr $i + 1`
if [ "$i" = "$selected" -o "$x" = "$selected" ]; then
rm -f "$HOME/.$PKG/profile"
ln -s "$PROFILE_DIR/$x" "$HOME/.$PKG/profile"
found=1
echo
if [ -n "$STY" ]; then
echo `gettext 'If you are using the default set of keybindings, press\n<F5> to activate these changes.\n\nOtherwise, exit this screen session and start a new one.'`